package com.kaifamiao.ioc.injection.test;

import com.kaifamiao.ioc.injection.Sinaean;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SetterBasedInjection {

    public static void main(String[] args) {

        // String configLocations = "classpath*:com/**/setter-based.xml";
        String configLocations = "classpath*:com/**/p-namespace.xml";

        // 创建容器
        AbstractApplicationContext container = new ClassPathXmlApplicationContext( configLocations );

        // 从容器中获取 Java Bean
        Sinaean a = container.getBean( "sanfeng", Sinaean.class );
        System.out.println( a );

        Sinaean b = container.getBean( "guoxiang", Sinaean.class );
        System.out.println( b );

        Sinaean c = container.getBean( "polu", Sinaean.class );
        System.out.println( c );

        // 关闭容器
        container.close();

    }

}
